﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace AspController
{
    public class BussinessModelController : ApiController
    {
        GroupDAL groupDAL;
        public BussinessModelController()
        {
            groupDAL = new GroupDAL();
        }
        // GET api/<controller>
        public IEnumerable<Group> Get()
        {
            return groupDAL.GetGroup().ToList();
        }

        // GET api/<controller>/5
        public Group Get(int id)
        {
            var group = groupDAL.GetGroup().ToList().Find(e => e.GroupID == id);
            return group;
        }

        // POST api/<controller>
        public void Post(Group group)
        {
            groupDAL.CreateGroup(group);
        }

       
        // PUT api/<controller>/5
        public void Put(int id, Group group)
        {
            var grp = groupDAL.GetGroup().ToList().Find(e => e.GroupID == group.GroupID);
            grp = group;
            groupDAL.UpdateGroup(grp);
        }

        // DELETE api/<controller>/5
        public void Delete(int id)
        {
            groupDAL.DeleteGroup(id);
        }
    }
}